<!DOCTYPE html>
<html lang="en">

<!-- Head tag -->
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="null">
    <meta name="keyword" content="null">
    <meta name="theme-color" content="#600090">
    <meta name="msapplication-navbutton-color" content="#600090">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="#600090">
    <link rel="shortcut icon" href="/assets/favicon.ico">
    <link rel="alternate" type="application/atom+xml" title="张小阳" href="/atom.xml">
    <link rel="stylesheet" href="https://cdn.bootcss.com/animate.css/3.5.2/animate.css">
    <link rel="stylesheet" href="https://cdn.bootcss.com/font-awesome/4.6.3/css/font-awesome.css">
    <title>
        
        vue移动端开发手册｜MillZhang&#39;s blog
        
    </title>

    <link rel="canonical" href="http://millzhang.github.io/2017/07/18/2017-note/27.vue移动端开发手册/">

    <!-- Bootstrap Core CSS -->
    <link rel="stylesheet" href="/css/bootstrap.min.css">

    <!-- Custom CSS -->
    <link rel="stylesheet" href="/css/blog-style.css">

    <!-- Pygments Github CSS -->
    <link rel="stylesheet" href="/css/syntax.css">
</head>

<!-- hack iOS CSS :active style -->
<body ontouchstart="" class="animated fadeIn">
<!-- Navigation -->
<nav class="navbar navbar-default navbar-custom navbar-fixed-top " id="nav-top" data-ispost = "true" data-istags="false
" data-ishome = "false" >
    <div class="container-fluid">
        <!-- Brand and toggle get grouped for better mobile display -->
        <div class="navbar-header page-scroll">
            <button type="button" class="navbar-toggle">
                <span class="sr-only">Toggle navigation</span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </button>
            <a class="navbar-brand animated pulse" href="/">
                <span class="brand-logo">
                    MillZhang
                </span>
            </a>
        </div>

        <!-- Collect the nav links, forms, and other content for toggling -->
        <!-- Known Issue, found by Hux:
            <nav>'s height woule be hold on by its content.
            so, when navbar scale out, the <nav> will cover tags.
            also mask any touch event of tags, unfortunately.
        -->
        <!-- /.navbar-collapse -->
        <div id="huxblog_navbar">
            <div class="navbar-collapse">
                <ul class="nav navbar-nav navbar-right">
                    <li>
                        <a href="/"><i class="fa fa-home"></i>主页</a>
                    </li>
                   <li>
                        <a href="/tags"><i class="fa fa-tags"></i>归档</a>
                    </li>
                    <li>
                        <a href="/about"><i class="fa fa-user"></i>关于</a>
                    </li>
                </ul>
            </div>
        </div>
    </div>
    <!-- /.container -->
</nav>
<script>
    // Drop Bootstarp low-performance Navbar
    // Use customize navbar with high-quality material design animation
    // in high-perf jank-free CSS3 implementation
//    var $body   = document.body;
    var $toggle = document.querySelector('.navbar-toggle');
    var $navbar = document.querySelector('#huxblog_navbar');
    var $collapse = document.querySelector('.navbar-collapse');

    $toggle.addEventListener('click', handleMagic)
    function handleMagic(e){
        if ($navbar.className.indexOf('in') > 0) {
        // CLOSE
            $navbar.className = " ";
            // wait until animation end.
            setTimeout(function(){
                // prevent frequently toggle
                if($navbar.className.indexOf('in') < 0) {
                    $collapse.style.height = "0px"
                }
            },400)
        }else{
        // OPEN
            $collapse.style.height = "auto"
            $navbar.className += " in";
        }
    }
</script>

<!-- Main Content -->

<!--only post-->

<header class="intro-header">
    <div class="container">
        <div class="row">
            <div class="col-lg-8 col-lg-offset-2 col-md-10 col-md-offset-1 text-center">
                <div class="post-heading">
                    <h1>vue移动端开发手册</h1>
                    
                    <span class="meta">
                         作者 MillZhang
                        <span>
                          日期 2017-07-18
                         </span>
                    </span>
                    <div class="tags text-center">
                        
                        <a class="tag" href="/tags/#javascript"
                           title="javascript">javascript</a>
                        
                        <a class="tag" href="/tags/#vue"
                           title="vue">vue</a>
                        
                        <a class="tag" href="/tags/#unfinished"
                           title="unfinished">unfinished</a>
                        
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="post-title-haojen">
        <span>
            vue移动端开发手册
        </span>
    </div>
    <div class="post-header-image">
        
            <img src="http://oritfw5nq.bkt.clouddn.com/wall-303.jpg?imageView2/0/format/jpg/interlace/1/q/85|watermark/2/text/QnkgTWlsbHpoYW5n/font/5b6u6L2v6ZuF6buR/fontsize/480/fill/I0ZERkRGRA==/dissolve/56/gravity/SouthEast/dx/10/dy/10|imageslim">
         
    </div>
</header>

<!-- Post Content -->
<article>
    <div class="container">
        <div class="row">
            <!-- Post Container -->
            <div class="col-lg-8 col-lg-offset-1 col-sm-9 post-container">
                <h3 id="package-json"><a href="#package-json" class="headerlink" title="package.json"></a>package.json</h3><figure class="highlight js"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div></pre></td><td class="code"><pre><div class="line"><span class="string">"font-awesome"</span>: <span class="string">"^4.7.0"</span>,<span class="comment">//字体</span></div><div class="line"><span class="string">"mint-ui"</span>: <span class="string">"^2.1.1"</span>,<span class="comment">//mint-ui</span></div><div class="line"><span class="string">"nprogress"</span>: <span class="string">"^0.2.0"</span>,<span class="comment">//加载进度条</span></div><div class="line"><span class="string">"vconsole"</span>: <span class="string">"^2.5.2"</span>,<span class="comment">//控制台调试</span></div><div class="line"><span class="string">"webpack-zepto"</span>: <span class="string">"0.0.1"</span>,<span class="comment">//zepto</span></div><div class="line"><span class="string">"weixin-js-sdk"</span>: <span class="string">"^1.2.0"</span>,<span class="comment">//微信js-sdk</span></div><div class="line"><span class="string">"node-sass"</span>: <span class="string">"^4.5.2"</span>,<span class="comment">//css-loader</span></div><div class="line"><span class="string">"sass-loader"</span>: <span class="string">"^6.0.3"</span>,</div><div class="line"><span class="string">"axios"</span>: <span class="string">"^0.16.1"</span>,</div><div class="line"><span class="string">"md5"</span>: <span class="string">"^2.2.1"</span>,</div></pre></td></tr></table></figure>
<h3 id="别名设置"><a href="#别名设置" class="headerlink" title="别名设置"></a>别名设置</h3><figure class="highlight js"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div></pre></td><td class="code"><pre><div class="line"><span class="string">'@'</span>: resolve(<span class="string">'src'</span>),</div><div class="line"><span class="string">'assets'</span>:resolve(<span class="string">'src/assets'</span>),</div><div class="line"><span class="string">'views'</span>:resolve(<span class="string">'src/views'</span>),</div><div class="line"><span class="string">'service'</span>:resolve(<span class="string">'src/service'</span>)</div></pre></td></tr></table></figure>
<h3 id="service-js"><a href="#service-js" class="headerlink" title="service.js"></a>service.js</h3><figure class="highlight js"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div><div class="line">28</div><div class="line">29</div><div class="line">30</div><div class="line">31</div><div class="line">32</div></pre></td><td class="code"><pre><div class="line"><span class="keyword">import</span> axios <span class="keyword">from</span> <span class="string">'axios'</span></div><div class="line"></div><div class="line">axios.defaults.baseURL = <span class="string">''</span>;</div><div class="line">axios.defaults.headers.post[<span class="string">'Content-Type'</span>] = <span class="string">'application/x-www-form-urlencoded'</span>;</div><div class="line"></div><div class="line"><span class="keyword">export</span> <span class="keyword">const</span> post = <span class="function"><span class="params">params</span> =&gt;</span> &#123;</div><div class="line">  <span class="keyword">return</span> POST_REQ(<span class="string">``</span>, params)</div><div class="line">&#125;</div><div class="line"></div><div class="line"></div><div class="line"><span class="keyword">export</span> <span class="keyword">const</span> get = <span class="function"><span class="params">params</span> =&gt;</span> &#123;</div><div class="line">  <span class="keyword">return</span> GET_REQ(<span class="string">``</span>, params);</div><div class="line">&#125;</div><div class="line"></div><div class="line"></div><div class="line"><span class="comment">/**</span></div><div class="line"> * get请求</div><div class="line"> * @param &#123;[type]&#125; url    [description]</div><div class="line"> * @param &#123;[type]&#125; params [description]</div><div class="line"> */</div><div class="line"><span class="function"><span class="keyword">function</span> <span class="title">GET_REQ</span>(<span class="params">url, params</span>) </span>&#123;</div><div class="line">  axios.get(url, &#123; <span class="attr">params</span>: params &#125;).then(<span class="function"><span class="params">res</span> =&gt;</span> res.data);</div><div class="line">&#125;</div><div class="line"></div><div class="line"><span class="comment">/**</span></div><div class="line"> * post请求</div><div class="line"> * @param &#123;[type]&#125; url    [description]</div><div class="line"> * @param &#123;[type]&#125; params [description]</div><div class="line"> */</div><div class="line"><span class="function"><span class="keyword">function</span> <span class="title">POST_REQ</span>(<span class="params">url, params</span>) </span>&#123;</div><div class="line">  <span class="keyword">return</span> axios.post(url, params).then(<span class="function"><span class="params">res</span> =&gt;</span> res.data);</div><div class="line">&#125;</div></pre></td></tr></table></figure>
<h3 id="通用原型挂载"><a href="#通用原型挂载" class="headerlink" title="通用原型挂载"></a>通用原型挂载</h3><figure class="highlight js"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div></pre></td><td class="code"><pre><div class="line"><span class="keyword">import</span> Service <span class="keyword">from</span> <span class="string">'service'</span></div><div class="line"><span class="keyword">import</span> Util <span class="keyword">from</span> <span class="string">'assets/js/Utils.js'</span></div><div class="line">Vue.prototype.service = Service;</div><div class="line">Vue.prototype.utils = Util;</div></pre></td></tr></table></figure>
<h3 id="路由标题修改"><a href="#路由标题修改" class="headerlink" title="路由标题修改"></a>路由标题修改</h3><figure class="highlight js"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div></pre></td><td class="code"><pre><div class="line">router.afterEach(<span class="function"><span class="params">transition</span> =&gt;</span> &#123;</div><div class="line">  <span class="keyword">if</span> (transition.name) &#123;</div><div class="line">    <span class="built_in">document</span>.title = transition.name;</div><div class="line">    <span class="keyword">let</span> u = navigator.userAgent;</div><div class="line">    <span class="keyword">let</span> isiOS = !!u.match(<span class="regexp">/\(i[^;]+;( U;)? CPU.+Mac OS X/</span>); <span class="comment">//ios终端</span></div><div class="line">    <span class="keyword">if</span> (isiOS) &#123;</div><div class="line">      <span class="keyword">let</span> i = <span class="built_in">document</span>.createElement(<span class="string">'iframe'</span>);</div><div class="line">      i.src = <span class="string">'http://m.baidu.com/favicon.ico'</span>;</div><div class="line">      i.style.display = <span class="string">'none'</span>;</div><div class="line">      i.onload = <span class="function"><span class="keyword">function</span>(<span class="params"></span>) </span>&#123;</div><div class="line">        setTimeout(<span class="function"><span class="keyword">function</span>(<span class="params"></span>) </span>&#123;</div><div class="line">          i.remove();</div><div class="line">        &#125;, <span class="number">0</span>);</div><div class="line">      &#125;;</div><div class="line">      <span class="built_in">document</span>.body.appendChild(i);</div><div class="line">    &#125;</div><div class="line">  &#125;</div><div class="line">  NProgress.done()</div><div class="line">&#125;);</div></pre></td></tr></table></figure>
<h3 id="commmon-css"><a href="#commmon-css" class="headerlink" title="commmon.css"></a>commmon.css</h3><figure class="highlight css"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div><div class="line">28</div><div class="line">29</div><div class="line">30</div><div class="line">31</div><div class="line">32</div><div class="line">33</div><div class="line">34</div><div class="line">35</div><div class="line">36</div><div class="line">37</div><div class="line">38</div><div class="line">39</div><div class="line">40</div><div class="line">41</div><div class="line">42</div><div class="line">43</div><div class="line">44</div><div class="line">45</div><div class="line">46</div><div class="line">47</div></pre></td><td class="code"><pre><div class="line">* &#123;</div><div class="line">  <span class="attribute">margin</span>: <span class="number">0</span>;</div><div class="line">  <span class="attribute">padding</span>: <span class="number">0</span>;</div><div class="line">  <span class="attribute">-webkit-overflow-scrolling</span>: touch;</div><div class="line">  <span class="attribute">-webkit-tap-highlight-color</span>: <span class="built_in">rgba</span>(0, 0, 0, 0);</div><div class="line">&#125;</div><div class="line"></div><div class="line"><span class="selector-tag">img</span> &#123;</div><div class="line">  <span class="attribute">border</span>: <span class="number">0</span>;</div><div class="line">&#125;</div><div class="line"></div><div class="line"><span class="selector-tag">a</span> &#123;</div><div class="line">  <span class="attribute">color</span>: inherit;</div><div class="line">  <span class="attribute">text-decoration</span>: none;</div><div class="line">&#125;</div><div class="line"></div><div class="line"><span class="selector-tag">a</span><span class="selector-pseudo">:active</span> &#123;</div><div class="line">  <span class="attribute">outline</span>: none;</div><div class="line">&#125;</div><div class="line"></div><div class="line"><span class="selector-tag">a</span><span class="selector-pseudo">:focus</span> &#123;</div><div class="line">  <span class="attribute">outline</span>: none;</div><div class="line">&#125;</div><div class="line"></div><div class="line"><span class="selector-class">.flex</span> &#123;</div><div class="line">  <span class="attribute">display</span>: flex;</div><div class="line">  <span class="attribute">display</span>: -webkit-flex;</div><div class="line">&#125;</div><div class="line"></div><div class="line"><span class="selector-class">.fr</span> &#123;</div><div class="line">  <span class="attribute">float</span>: right;</div><div class="line">&#125;</div><div class="line"></div><div class="line"><span class="selector-class">.clear</span><span class="selector-pseudo">:after</span> &#123;</div><div class="line">  <span class="attribute">content</span>: <span class="string">""</span>;</div><div class="line">  <span class="attribute">display</span>: table;</div><div class="line">  <span class="attribute">clear</span>: both;</div><div class="line">&#125;</div><div class="line"></div><div class="line"><span class="selector-tag">textarea</span> &#123;</div><div class="line">  <span class="attribute">border</span>: none;</div><div class="line">  <span class="attribute">resize</span>: none;</div><div class="line">&#125;</div><div class="line"></div><div class="line"><span class="selector-tag">textarea</span><span class="selector-pseudo">:focus</span> &#123;</div><div class="line">  <span class="attribute">outline</span>: none;</div><div class="line">&#125;</div></pre></td></tr></table></figure>
<h3 id="font-scss"><a href="#font-scss" class="headerlink" title="font.scss"></a>font.scss</h3><figure class="highlight"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div><div class="line">28</div><div class="line">29</div><div class="line">30</div><div class="line">31</div><div class="line">32</div><div class="line">33</div><div class="line">34</div><div class="line">35</div><div class="line">36</div><div class="line">37</div><div class="line">38</div><div class="line">39</div><div class="line">40</div><div class="line">41</div><div class="line">42</div><div class="line">43</div><div class="line">44</div><div class="line">45</div><div class="line">46</div><div class="line">47</div><div class="line">48</div><div class="line">49</div><div class="line">50</div><div class="line">51</div><div class="line">52</div><div class="line">53</div><div class="line">54</div><div class="line">55</div><div class="line">56</div><div class="line">57</div><div class="line">58</div><div class="line">59</div><div class="line">60</div><div class="line">61</div><div class="line">62</div><div class="line">63</div><div class="line">64</div><div class="line">65</div><div class="line">66</div><div class="line">67</div><div class="line">68</div><div class="line">69</div><div class="line">70</div><div class="line">71</div><div class="line">72</div><div class="line">73</div><div class="line">74</div><div class="line">75</div><div class="line">76</div><div class="line">77</div><div class="line">78</div><div class="line">79</div><div class="line">80</div><div class="line">81</div><div class="line">82</div><div class="line">83</div><div class="line">84</div><div class="line">85</div><div class="line">86</div><div class="line">87</div><div class="line">88</div><div class="line">89</div><div class="line">90</div><div class="line">91</div><div class="line">92</div><div class="line">93</div><div class="line">94</div><div class="line">95</div><div class="line">96</div><div class="line">97</div><div class="line">98</div><div class="line">99</div><div class="line">100</div><div class="line">101</div><div class="line">102</div><div class="line">103</div><div class="line">104</div><div class="line">105</div><div class="line">106</div><div class="line">107</div><div class="line">108</div><div class="line">109</div><div class="line">110</div><div class="line">111</div><div class="line">112</div><div class="line">113</div></pre></td><td class="code"><pre><div class="line">$font-12:12px;</div><div class="line">$font-14:14px;</div><div class="line">$font-10:10px;</div><div class="line">$font-16:16px;</div><div class="line">$font-18:18px;</div><div class="line">//默认字号</div><div class="line">[data-dpr="1"] &#123;</div><div class="line">    * &#123;</div><div class="line">        font-size: $font-14;</div><div class="line">    &#125;</div><div class="line">&#125;</div><div class="line"></div><div class="line">[data-dpr="2"] &#123;</div><div class="line">    * &#123;</div><div class="line">        font-size: $font-14*2;</div><div class="line">    &#125;</div><div class="line">&#125;</div><div class="line"></div><div class="line">[data-dpr="3"] &#123;</div><div class="line">    * &#123;</div><div class="line">        font-size: $font-14*3;</div><div class="line">    &#125;</div><div class="line">&#125;</div><div class="line"></div><div class="line">[data-dpr="1"] &#123;</div><div class="line">    .f10 &#123;</div><div class="line">        font-size: $font-10;</div><div class="line">    &#125;</div><div class="line">&#125;</div><div class="line"></div><div class="line">[data-dpr="2"] &#123;</div><div class="line">    .f10 &#123;</div><div class="line">        font-size: $font-10*2;</div><div class="line">    &#125;</div><div class="line">&#125;</div><div class="line"></div><div class="line">[data-dpr="3"] &#123;</div><div class="line">    .f10 &#123;</div><div class="line">        font-size: $font-10*3;</div><div class="line">    &#125;</div><div class="line">&#125;</div><div class="line"></div><div class="line">[data-dpr="1"] &#123;</div><div class="line">    .f12 &#123;</div><div class="line">        font-size: $font-12;</div><div class="line">    &#125;</div><div class="line">&#125;</div><div class="line"></div><div class="line">[data-dpr="2"] &#123;</div><div class="line">    .f12 &#123;</div><div class="line">        font-size: $font-12*2;</div><div class="line">    &#125;</div><div class="line">&#125;</div><div class="line"></div><div class="line">[data-dpr="3"] &#123;</div><div class="line">    .f12 &#123;</div><div class="line">        font-size: $font-12*3;</div><div class="line">    &#125;</div><div class="line">&#125;</div><div class="line"></div><div class="line">[data-dpr="1"] &#123;</div><div class="line">    .f14 &#123;</div><div class="line">        font-size: $font-14;</div><div class="line">    &#125;</div><div class="line">&#125;</div><div class="line"></div><div class="line">[data-dpr="2"] &#123;</div><div class="line">    .f14 &#123;</div><div class="line">        font-size: $font-14*2;</div><div class="line">    &#125;</div><div class="line">&#125;</div><div class="line"></div><div class="line">[data-dpr="3"] &#123;</div><div class="line">    .f14 &#123;</div><div class="line">        font-size: $font-14*3;</div><div class="line">    &#125;</div><div class="line">&#125;</div><div class="line"></div><div class="line">[data-dpr="1"] &#123;</div><div class="line">    .f16 &#123;</div><div class="line">        font-size: $font-16;</div><div class="line">    &#125;</div><div class="line">&#125;</div><div class="line"></div><div class="line">[data-dpr="2"] &#123;</div><div class="line">    .f16 &#123;</div><div class="line">        font-size: $font-16*2;</div><div class="line">    &#125;</div><div class="line">&#125;</div><div class="line"></div><div class="line">[data-dpr="3"] &#123;</div><div class="line">    .f16 &#123;</div><div class="line">        font-size: $font-16*3;</div><div class="line">    &#125;</div><div class="line">&#125;</div><div class="line"></div><div class="line">[data-dpr="1"] &#123;</div><div class="line">    .f18 &#123;</div><div class="line">        font-size: $font-18;</div><div class="line">    &#125;</div><div class="line">&#125;</div><div class="line"></div><div class="line">[data-dpr="2"] &#123;</div><div class="line">    .f18 &#123;</div><div class="line">        font-size: $font-18*2;</div><div class="line">    &#125;</div><div class="line">&#125;</div><div class="line"></div><div class="line">[data-dpr="3"] &#123;</div><div class="line">    .f18 &#123;</div><div class="line">        font-size: $font-18*3;</div><div class="line">    &#125;</div><div class="line">&#125;</div></pre></td></tr></table></figure>
<h3 id="flexible-js"><a href="#flexible-js" class="headerlink" title="flexible.js"></a>flexible.js</h3><blockquote>
<p><a href="http://oritfw5nq.bkt.clouddn.com/flexible.js" target="_blank" rel="external">http://oritfw5nq.bkt.clouddn.com/flexible.js</a></p>
</blockquote>
<h3 id="filter-js"><a href="#filter-js" class="headerlink" title="filter.js"></a>filter.js</h3><figure class="highlight js"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div><div class="line">28</div><div class="line">29</div><div class="line">30</div><div class="line">31</div></pre></td><td class="code"><pre><div class="line"><span class="keyword">import</span> Vue <span class="keyword">from</span> <span class="string">'vue'</span></div><div class="line"></div><div class="line"><span class="comment">/**</span></div><div class="line"> * vue渲染时间值</div><div class="line"> * @param  &#123;[type]&#125; value [description]</div><div class="line"> * @return &#123;[type]&#125;       [description]</div><div class="line"> */</div><div class="line">Vue.filter(<span class="string">'time'</span>, <span class="function"><span class="keyword">function</span>(<span class="params">value</span>) </span>&#123;</div><div class="line">  <span class="keyword">let</span> fmt = <span class="string">'yyyy-MM-dd'</span>,</div><div class="line">    date = <span class="keyword">new</span> <span class="built_in">Date</span>(value);</div><div class="line">  <span class="keyword">let</span> o = &#123;</div><div class="line">    <span class="string">"M+"</span>: date.getMonth() + <span class="number">1</span>, <span class="comment">//月份</span></div><div class="line">    <span class="string">"d+"</span>: date.getDate(), <span class="comment">//日</span></div><div class="line">    <span class="string">"h+"</span>: date.getHours(), <span class="comment">//小时</span></div><div class="line">    <span class="string">"m+"</span>: date.getMinutes(), <span class="comment">//分</span></div><div class="line">    <span class="string">"s+"</span>: date.getSeconds(), <span class="comment">//秒</span></div><div class="line">    <span class="string">"q+"</span>: <span class="built_in">Math</span>.floor((date.getMonth() + <span class="number">3</span>) / <span class="number">3</span>), <span class="comment">//季度</span></div><div class="line">    <span class="string">"S"</span>: date.getMilliseconds() <span class="comment">//毫秒</span></div><div class="line">  &#125;;</div><div class="line">  <span class="keyword">if</span> (<span class="regexp">/(y+)/</span>.test(fmt)) fmt = fmt.replace(<span class="built_in">RegExp</span>.$<span class="number">1</span>, (date.getFullYear() + <span class="string">""</span>).substr(<span class="number">4</span> - <span class="built_in">RegExp</span>.$<span class="number">1.</span>length));</div><div class="line">  <span class="keyword">for</span> (<span class="keyword">let</span> k <span class="keyword">in</span> o)</div><div class="line">    <span class="keyword">if</span> (<span class="keyword">new</span> <span class="built_in">RegExp</span>(<span class="string">"("</span> + k + <span class="string">")"</span>).test(fmt)) fmt = fmt.replace(<span class="built_in">RegExp</span>.$<span class="number">1</span>, (<span class="built_in">RegExp</span>.$<span class="number">1.</span>length == <span class="number">1</span>) ? (o[k]) : ((<span class="string">"00"</span> + o[k]).substr((<span class="string">""</span> + o[k]).length)));</div><div class="line">  <span class="keyword">return</span> fmt;</div><div class="line">&#125;);</div><div class="line"></div><div class="line">Vue.filter(<span class="string">'money'</span>, <span class="function"><span class="keyword">function</span>(<span class="params">value</span>) </span>&#123;</div><div class="line">  <span class="keyword">if</span> (<span class="literal">undefined</span> == value) &#123;</div><div class="line">    <span class="keyword">return</span> <span class="string">'0.00'</span>;</div><div class="line">  &#125;</div><div class="line">  <span class="keyword">return</span> <span class="built_in">Number</span>(value).toFixed(<span class="number">2</span>);</div><div class="line">&#125;);</div></pre></td></tr></table></figure>
                <hr>
                <ul class="pager">
                    
                    <li class="previous">
                        <a href="/2017/07/18/2017-note/28.开发笔记/" data-toggle="tooltip" data-placement="top"
                           title="开发笔记">&larr; 上一页</a>
                    </li>
                    
                    
                    <li class="next">
                        <a href="/2017/07/11/2017-note/26.vue文档纪要/" data-toggle="tooltip" data-placement="top"
                           title="vue文档纪要">下一页 &rarr;</a>
                    </li>
                    
                </ul>
                <div class="comment">
                    <div id="cloud-tie-wrapper" class="cloud-tie-wrapper"></div>
                </div>
            </div>
            <div class="hidden-xs col-sm-3 toc-col">
                <div class="toc-wrap">
                    <ol class="toc"><li class="toc-item toc-level-3"><a class="toc-link" href="#package-json"><span class="toc-text">package.json</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#别名设置"><span class="toc-text">别名设置</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#service-js"><span class="toc-text">service.js</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#通用原型挂载"><span class="toc-text">通用原型挂载</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#路由标题修改"><span class="toc-text">路由标题修改</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#commmon-css"><span class="toc-text">commmon.css</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#font-scss"><span class="toc-text">font.scss</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#flexible-js"><span class="toc-text">flexible.js</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#filter-js"><span class="toc-text">filter.js</span></a></li></ol>
                </div>
            </div>
        </div>

        <div class="row">
            <!-- Sidebar Container -->

            <div class="
                col-lg-8 col-lg-offset-2
                col-md-10 col-md-offset-1
                sidebar-container">

                <!-- Featured Tags -->
                

                <!-- Friends Blog -->
                
            </div>
        </div>

    </div>
</article>
<!-- 网易云音乐-->

<iframe class="cloud-music" frameborder="no" border="0" marginwidth="0" marginheight="0" width=330 height=86 
    src="//music.163.com/outchain/player?type=2&amp;id=18803411&amp;auto=0&amp;height=66">
</iframe>
<!-- 网易云跟帖-->
<script src="https://img1.cache.netease.com/f2e/tie/yun/sdk/loader.js"></script>
<script>
var cloudTieConfig = {
  url: document.location.href, 
  sourceId: "",
  productKey: "40a8ee22b6084862a8907e6902e525fa",
  target: "cloud-tie-wrapper"
};
var yunManualLoad = true;
Tie.loader("aHR0cHM6Ly9hcGkuZ2VudGllLjE2My5jb20vcGMvbGl2ZXNjcmlwdC5odG1s", true);
</script>

<!-- Footer -->
<!-- Footer -->
<footer>
    <div class="container">
        <div class="row">
            <div class="col-lg-8 col-lg-offset-2 col-md-10 col-md-offset-1 text-center">
                <p class="copyright text-muted">
                    Copyright &copy; MillZhang 2017
                    <br>
                </p>
            </div>
        </div>
    </div>
</footer>

<!-- jQuery -->
<script src="/js/jquery.min.js"></script>

<!-- Bootstrap Core JavaScript -->
<script src="/js/bootstrap.min.js"></script>

<!-- Custom Theme JavaScript -->
<script src="/js/blog.js"></script>

<!-- async load function -->
<script>
    function async(u, c) {
      var d = document, t = 'script',
          o = d.createElement(t),
          s = d.getElementsByTagName(t)[0];
      o.src = u;
      if (c) { o.addEventListener('load', function (e) { c(null, e); }, false); }
      s.parentNode.insertBefore(o, s);
    }
</script>

<!-- jquery.tagcloud.js -->
<script>
    // only load tagcloud.js in tag.html
    if($('#tag_cloud').length !== 0){
        async("http://oritfw5nq.bkt.clouddn.com/jquery.tagcloud.js",function(){
            $.fn.tagcloud.defaults = {
                //size: {start: 1, end: 1, unit: 'em'},
                color: {start: '#bbbbee', end: '#0085a1'},
            };
            $('#tag_cloud a').tagcloud();
        })
    }
</script>

<!--fastClick.js -->
<script>
    async("//cdn.bootcss.com/fastclick/1.0.6/fastclick.min.js", function(){
        var $nav = document.querySelector("nav");
        if($nav) FastClick.attach($nav);
    })
</script>



<!--wechat title img-->
<img class="wechat-title-img" src="http://oritfw5nq.bkt.clouddn.com/avatar.jpg?imageslim">
<a id="backtop" class="border-bottom" href="javascript:;">回顶部</a>
<script type="application/javascript">
var docOuter = document.body.scrollTop ? document.body : document.documentElement;
var backToTop = function(rate) {
  var doc = document.body.scrollTop ? document.body : document.documentElement;
  var scrollTop = doc.scrollTop;
  var top = function() {
    scrollTop = scrollTop + (0 - scrollTop) / (rate || 2);
    if (scrollTop < 1) {
      doc.scrollTop = 0;
      return;
    }
    doc.scrollTop = scrollTop;
    // 动画gogogo!
    requestAnimationFrame(top);
  };
  top();
};
var topBtn = document.getElementById('backtop'),
    docTop = docOuter.scrollTop;
if(docTop>=300){
  topBtn.style.opacity = 1;
}

topBtn.onclick = function() {
  backToTop(12)
}
window.onscroll = function(e) {
  var doc = document.body.scrollTop ? document.body : document.documentElement;
  var scrollTop = doc.scrollTop;
  if (scrollTop >= 300) {
    topBtn.style.opacity = 1;
  } else {
    topBtn.style.opacity = 0;
  }
}
</script>
</body>

</html>
